package app.caihan.wanandroid.model.db

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import app.caihan.wanandroid.model.bean.BannerBean
import app.caihan.wanandroid.model.bean.Chapters
import app.caihan.wanandroid.model.bean.User

/**
 *
 *
 * @author Seven-C
 * @date 2020/8/20
 */
@Dao
interface WanDao {

    @Query("SELECT * FROM BannerBean")
    suspend fun getBannerList(): List<BannerBean>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertBanner(banners: List<BannerBean>)

    @Query("DELETE FROM BannerBean")
    suspend fun deleteBannerAll()


    @Query("SELECT * FROM Chapters")
    suspend fun getWxArticleChapters(): List<Chapters>

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertChapters(chapters: List<Chapters>)

    @Query("DELETE FROM Chapters")
    suspend fun deleteChaptersAll()

    @Query("SELECT * FROM User")
    suspend fun getUserInfo(): User

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insertUserInfo(user: User)

    @Query("DELETE FROM User")
    suspend fun deleteUserInfo()
}